package com.crm.base.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.crm.base.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-07-12
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT r.name FROM t_user_role ur JOIN  t_role r ON r.rid = ur.rid WHERE ur.uid = 1\n" +
            "UNION\n" +
            "SELECT DISTINCT p.name FROM t_user_role ur JOIN t_role_permission rp ON rp.rid = ur.rid JOIN t_permission p ON rp.pid=p.pid WHERE ur.uid=1 ")
    List<String> findAllByPermissions(User user);

}
